import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    meta: {
      title: '主页'
    }
  },
  {
    path: '/school/news',
    name: 'SchoolNews',
    component: () => import('../views/school/news.vue'),
    meta: {
      title: '学校新闻'
    }
  },
  {
    path: '/school/orgs',
    name: 'SchoolOrgs',
    component: () => import('../views/school/orgs.vue'),
    meta: {
      title: '组织机构'
    }
  },
  {
    path: '/about',
    name: 'About',
    component: () => import('../views/About.vue'),
    meta: {
      title: '关于'
    }
  },
  {
    path: '/user/:userCode',
    name: 'User',
    component: () => import('../views/UserTpl.vue'),
    meta: {
      title: '用户'
    }
  },
  {
    path: '/bpmnViewer',
    name: 'BpmnViewer',
    component: () => import('../views/BpmnViewerTpl.vue'),
    meta: {
      title: '流程查看'
    }
  },
  {
    path: '/bpmnModeler',
    name: 'BpmnModeler',
    component: () => import('../views/BpmnModelerTpl.vue'),
    meta: {
      title: '流程设计'
    }
  },
  {
    path: '/BpmnPropertyt',
    name: 'bpmnPropertyt',
    component: () => import('../views/BpmnPropertytTpl.vue'),
    meta: {
      title: '流程设计属性'
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
})
export default router
